﻿using System;

using Fuse8.DomainFramework.Common;

using Fuse8.ContentManagementFramework.Domain.Special;

namespace Fuse8.ContentManagementFramework.Administration.Models
{
    [Serializable]
    public class CmsAdminRevisionViewModel
    {
        public int Id { get; set; }

        public int LatestRevisionId { get; set; }

        public string EntityName { get; set; }

        public string Author { get; set; }

        public DateTime CreationDate { get; set; }

        public bool IsLatestRevision { get; set; }

        public bool IsLatestCompletedRevision { get; set; }

        public bool IsPublished { get; set; }

        public CmsAdminRevisionViewModel(CmsRevisionableEntityObject entity)
        {
            Guard.ArgumentNotNull(entity, "entity");

            CreationDate = entity.DateLastUpdated.GetValueOrDefault(entity.DateCreated);
            IsLatestRevision = entity.IsLatestRevision.GetValueOrDefault(false);
            IsLatestCompletedRevision = entity.IsLatestCompletedRevision.GetValueOrDefault(false);
            IsPublished = entity.IsCurrentlyPublished;
        }
    }
}